
package com.kzd.sdk.ui.fragment;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.kzd.sdk.base.OwnerFragment;
import com.kzd.sdk.callback.KZD_OnAccessListener;
import com.kzd.sdk.utils.AppUtils;

public class KZD_AccessVerifyFragment extends OwnerFragment {


    private EditText etAccessVerifyCardName, etAccessVerifyCardCode;

    public KZD_OnAccessListener mOnAccessListener;

    public void setOnAccessListener(KZD_OnAccessListener onAccessListener) {
        this.mOnAccessListener = onAccessListener;
    }

    @Override
    public String getLayoutIdByName() {
        return "kzd_fragment_access_verify";
    }

    @Override
    public void initView(View view) {
        etAccessVerifyCardName = view.findViewById(AppUtils.getId(mContext, "etAccessVerifyCardName"));
        etAccessVerifyCardCode = view.findViewById(AppUtils.getId(mContext, "etAccessVerifyCardCode"));

        view.findViewById(AppUtils.getId(mContext, "ivAccessVerifyBack"))
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (mOnClickListener != null) {
                            mOnClickListener.onClick(v);
                        }
                    }
                });

        view.findViewById(AppUtils.getId(mContext, "tvAccessVerifySubmit"))
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String cardName = etAccessVerifyCardName.getText().toString();
                        String cardCode = etAccessVerifyCardCode.getText().toString();
                        if (TextUtils.isEmpty(cardName)) {
                            toast("请输入姓名");
                            return;
                        }
                        if (TextUtils.isEmpty(cardCode)) {
                            toast("请输入身份证号");
                            return;
                        }
                        if (mOnAccessListener != null) {
                            mOnAccessListener.onVerify(cardName, cardCode);
                        }
                    }
                });
    }

}
